package com.huangliusong.demohls;

import org.springframework.expression.EvaluationContext;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.SimpleEvaluationContext;

public class StringUtils {
    public static String reverseString(String input) {
        StringBuilder backwards = new StringBuilder(input.length());
        for (int i = 0; i < input.length(); i++){
            backwards.append(input.charAt(input.length() - 1 - i));
        }
        return backwards.toString();
    }
    public static void main(String[] args) throws  Exception{
        String s=StringUtils.reverseStr("huangliusong");
        System.err.println(s);
        test1();
    }

    public static String reverseStr(String input){
        StringBuilder stringBuilder=new StringBuilder(input.length());
        for (int i=0;i<input.length();i++){
            stringBuilder.append(input.charAt(input.length()-1-i));
        }
        return stringBuilder.toString();
    }

    public static  void test1() throws Exception{
        ExpressionParser parser=new SpelExpressionParser();
        EvaluationContext context = SimpleEvaluationContext.forReadOnlyDataBinding().build();
        context.setVariable("reverseString",
                StringUtils.class.getDeclaredMethod("reverseString", String.class));
        String hw=parser.parseExpression("#reverseString('hls')").getValue(context,String.class);

        System.err.println(hw);



    }
}
